package edu.wpi.cs509.ui.intfc;

import edu.wpi.cs509.representation.Location;
import edu.wpi.cs509.representation.PlayerPiece;

/**
 * This interface defines the methods that the Client Logic will
 * invoke to notify the UI of asynchronous game events
 * 
 * @author afoltan
 *
 */
public interface GameEventNotify {
	
	public enum FailureReason {
		IllegalMove,
	};

	
	/**
	 * Indicates a piece on the board has moved positions.
	 * The UI will refresh the GameBoard display and indicate the player move.
	 * 
	 * @param from - the location the piece is moving from
	 * @param to - the location the piece is moving to
	 * 
	 * @note All arguments must be valid objects and cannot be null
	 */
	void notifyPieceMoved( PlayerPiece piece, Location from, Location to );  // this version when redrawing the move only

	/**
	 * Indicates a piece has been placed on the board from the graveyard.
	 * The graveyard will be decremented to remove this piece.
	 * @param piece - the piece being moved from the graveyard to the board
	 * @param location - the location on the board where the piece is to be placed
	 * 
	 * @note All arguments must be valid objects and cannot be null
	 */
	void notifyPiecePlaced( PlayerPiece piece, Location location );
	/**
	 * Indicates a piece has been placed back in the graveyard from the board..
	 * The graveyard will be incremented to accommodate this piece.
	 * @param piece - the piece being moved to the graveyard from the board
	 * @param location - the location on the board where the piece is to be removed from
	 */
	void notifyPieceRemoved( PlayerPiece piece, Location location );

	/**
	 * Indicates the game board has been modified.
	 * The UI will refresh the entire GameBoard display. 
	 */
	void notifyRefreshGameBoard();					// this version when redrawing the entire board
	
	/**
	 * Indicates a piece has attacked another piece.  This will occur irrespective of
	 * which player initiates the attack.
	 * The UI will use this to event to display the 'battle' scene.
	 * 
	 * @param attacker - the attacking piece (note the piece location is the post-attack location)
	 * @param from - the original board square of the attacker piece
	 * @param defender - the defender piece (note the piece location is the post-attack location)
	 * @param to - the original board square of the defending piece
	 * 
	 * @note All arguments must be valid objects and cannot be null
	 */
	void notifyAttack( PlayerPiece attacker, Location from, PlayerPiece defender, Location to );
	
	/**
	 * Indicates that both players have finalized their piece placement
	 * The UI will refresh the GameBoard display and show empty grave yards
	 * instead of the initial placement panel.
	 */
	void notifyGameStarted();
	
	/**
	 * Indicates the game is ended.
	 * The UI will pop-up a dialog indicating the victory/defeat status of the player.
	 * 
	 * @param winner - true if user won the game, false otherwise
	 */
	void notifyGameOver( boolean winner );
	
	//
	//	UNSOLICITED GAME NOTIFICATIONS
	//
	
	/**
	 * Indicates that an opponent has joined your game.  The UI will update 
	 * the opponent graveyard to indicate the opponent name and track the
	 * opponent initial piece placement.
	 */
	void notifyOpponentJoined();
	
	/**
	 * Indicates that the opponent has quit the game.  The UI will display 
	 * a pop-up dialog indicating the opponent has resigned.
	 */
	void notifyOpponentQuit();

	/**
	 * Indicates that the opponent has "Readied-up".  This means all their 
	 * pieces have been placed and submitted, and they are ready to play.
	 * 
	 * The UI will change the opponent graveyard from the initial placement
	 * display to the game view.
	 */
	void notifyOpponentReady();

	/**
	 * Indicates the opponents turn has ended and it is now the local players turn.
	 * The UI will show an indicator that it is now the players turn.
	 */
	void notifyItsYourTurn();

	/**
	 * Asynchronous notification for failures
	 */
	void notifyFailure( FailureReason reason );

}
